# 问题1：筛选前10名并写入 candid1.txt
def One():
    students = []
    with open("score.txt", "r", encoding="utf-8") as f:#简化代码
        for line in f:
            data = line.strip().split()
            scores = list(map(int, data[2:12]))
            if all(score >= 60 for score in scores):
                total = sum(scores)
                students.append((total, data))

    # 按总成绩降序排序，取前10
    students.sort(reverse=True, key=lambda x: x[0])
    top10 = students[:10]

    with open("candid1.txt", "w", encoding="utf-8") as f:
        for item in top10:
            f.write(" ".join(item[1]) + "\n")


# 问题2：提取学号和姓名到 candid2.txt
def Two():
    with open("candid1.txt", "r", encoding="utf-8") as f1, \
            open("candid2.txt", "w", encoding="utf-8") as f2:
        for line in f1:
            data = line.strip().split()
            f2.write(f"{data[0]}{data[1]}\n")


# 执行
One()
Two()
